import {defineStore} from 'pinia'
import {
    requestCouponInfoDetail,
    requestCouponInfoList,
    requestCouponInfoQueryReceivet,
    requestCouponInfoSave,
    requestCouponInfoUpdate,
    requestCouponInfoUpdateStatus,
    CouponInfo,
    CouponInfoList,
    CouponStatus,
    QueryReceivet
} from '../service/coupon'

// 优惠券管理
export default defineStore('useCouponStore', () => {

    // 优惠劵详情
    const couponInfoDetail = async (id: number) => {
        const res = await requestCouponInfoDetail(id)
        // console.log(res, "| res");
        return res?.data
    }

    // 查询优惠券列表
    const couponInfoList = async (couponInfoList: Partial<CouponInfoList>) => {
        const res = await requestCouponInfoList(couponInfoList)
        console.log(res, "| res");
    }

    // 查询领取记录列表
    const couponInfoQueryReceivet = async (queryReceivet: Partial<QueryReceivet>) => {
        const res = await requestCouponInfoQueryReceivet(queryReceivet)
        console.log(res, "| res");
    }

    // 新增优惠券
    const couponInfoSave = async (couponInfo: Partial<CouponInfo>) => {
        const res = await requestCouponInfoSave(couponInfo)
        console.log(res, "| res");
    }

    // 更新优惠券
    const couponInfoUpdate = async (couponInfo: Partial<CouponInfo>) => {
        const res = await requestCouponInfoUpdate(couponInfo)
        console.log(res, "| res");
    }

    // 更新优惠券状态
    const couponInfoUpdateStatus = async (couponStatus: Partial<CouponStatus>) => {
        const res = await requestCouponInfoUpdateStatus(couponStatus)
        console.log(res, "| res");
    }

    return {
        couponInfoDetail,
        couponInfoList,
        couponInfoQueryReceivet,
        couponInfoSave,
        couponInfoUpdate,
        couponInfoUpdateStatus
    }
})